package cn.iocoder.yudao.module.shop.service.order.handler;

import cn.iocoder.yudao.module.shop.dal.dataobject.order.ShopOrderDO;
import cn.iocoder.yudao.module.shop.dal.dataobject.order.ShopOrderItemDO;

import java.util.List;

/**
 * 订单活动特殊逻辑处理器 handler 接口
 * 提供订单生命周期钩子接口；订单创建前、订单创建后、订单支付后、订单取消
 *
 * @author 曹建伟
 */
public interface ShopOrderHandler {
    /**
     * 订单创建前
     *
     * @param order 订单
     * @param orderItems 订单项
     */
    default void beforeOrderCreate(ShopOrderDO order, List<ShopOrderItemDO> orderItems) {}

    /**
     * 订单创建后
     *
     * @param order 订单
     * @param orderItems 订单项
     */
    default void afterOrderCreate(ShopOrderDO order, List<ShopOrderItemDO> orderItems) {}

    /**
     * 支付订单后
     *
     * @param order 订单
     */
    default void afterPayOrder(ShopOrderDO order, List<ShopOrderItemDO> orderItems) {}

    /**
     * 订单取消后
     *
     * @param order 订单
     * @param orderItems 订单项
     */
    default void afterCancelOrder(ShopOrderDO order, List<ShopOrderItemDO> orderItems) {}

    /**
     * 订单项取消后
     *
     * @param order 订单
     * @param orderItem 订单项
     */
    default void afterCancelOrderItem(ShopOrderDO order, ShopOrderItemDO orderItem) {}

    default void rollbackOrder(ShopOrderDO order, List<ShopOrderItemDO> orderItems){}
}
